package com.itheima.utils;


import javax.sql.DataSource;
import java.io.IOException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Properties;

/*德鲁伊连接池的工具类，主要功能是简化连接池的使用
* 提供获取加载配置文件的，获取连接池对象的功能*/
public class JDBCDruidUtils {
    /*关流大法*/
    public static void close(PreparedStatement pstm,Connection connection) {
        close(null,pstm,connection);
    }

    /*关流大法*/
    public static void close( ResultSet rs,PreparedStatement pstm,Connection connection) {
        if (connection != null) {
            try {
                connection.close();
            } catch (SQLException e) {
                e.printStackTrace();
            }
        }
        if (pstm != null) {
            try {
                pstm.close();
            } catch (SQLException e) {
                e.printStackTrace();
            }
        }
        if (rs != null) {
            try {
                rs.close();
            } catch (SQLException e) {
                e.printStackTrace();
            }
        }
    }
}
